package dyyx;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.rpc.cluster.loadbalance.RandomLoadBalance;

public class ClientMain {

	public static void main(final String[] args) {
		
		ApplicationConfig application = new ApplicationConfig();
		application.setName("dubbo-client-main");
		
		RegistryConfig registryConfig = new RegistryConfig();
		registryConfig.setProtocol("zookeeper");
		registryConfig.setAddress("127.0.0.1:2181");
		registryConfig.setClient("zkclient");
		
		ReferenceConfig<HelloService> referenceConfig = new ReferenceConfig<>();
		referenceConfig.setApplication(application);
		referenceConfig.setRegistry(registryConfig);
		// random  roundrobin leastactive 
		referenceConfig.setLoadbalance(RandomLoadBalance.NAME);
		referenceConfig.setInterface(HelloService.class);
		referenceConfig.setVersion("1.0.0");
		referenceConfig.setGroup("group1");
		
		// 一般使用version 即可
		
		HelloService helloService = referenceConfig.get();
		String result = helloService.hello("dyyx");
		
		System.out.println(result);


		
		
		
		
	}

}
